package com.hackerrank.challenges.ipaddressvalidation;

import java.util.Scanner;

public class Solution {
	private static final String NEITHER = "Neither";
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		in.nextLine();
		for(int i = 0; i < N; i++) {
			String s = in.nextLine().trim();
			if(s.matches("[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+"))
				System.out.println("IPv6");
			else if(s.matches("([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"))
				System.out.println("IPv4");
			else
				System.out.println(NEITHER);
		}
	}
}
